#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/kfifo.h>

/*
	模块的初始化; lkp_init(); 
	 */
int test_kfifo(void){
	struct kfifo fifo; 
	int ret = 0; 
	unsigned int i = 0; 
	ret = kfifo_alloc(&fifo, PAGE_SIZE,GFP_KERNEL ); 

	printk("ret = %d\n", ret); 
	if(ret){
		return ret; 
	}

	for(i = 0; i<32; i++){
		kfifo_in(&fifo,&i, sizeof(i)); 
	}
	
	while(kfifo_avail(fifo)){
		unsigned int val ; 
		int ret; 

		ret = kfifo_out(fifo,&val, sizeof(val)); 
		if (ret != sizeof(val))
			return -EINVAL; 
		printk(KERN_INFO, "%u\n",val); 
	}
}
static int __init lkp_init(void)
{
	printk("hello,world\n"); 
	return 0; 
}


/*
	 模块的退出和清理; 
	 */

static void __exit lkp_exit(void)
{
	printk("Good Bye\n"); 
}

module_init(lkp_init); 
module_exit(lkp_exit); 

/*
	模块的代码许可; 
	 */
MODULE_LICENSE("GPL"); 
